import request from '@/utils/request'
/*
  params 会自动进行url拼接，其它类似name、search这些则不会自动拼接
*/

// 用户增删改查
export function listUser(params) {
  return request({
    url: '/user/',
    method: 'get',
    params
  })
}

// 检查用户名是否存在
export function checkUsername(params) {
  return request({
    url: '/check/username/',
    method: 'get',
    params
  })
}

// 检查手机号是否存在
export function checkMobile(params) {
  return request({
    url: '/check/mobile/',
    method: 'get',
    params
  })
}

export function addUser(data) {
  return request({
    url: '/user/',
    method: 'post',
    data
  })
}

export function editUser(id, data) {
  return request({
    url: '/user/' + id + '/',
    method: 'put',
    data
  })
}

export function viewUser(id) {
  return request({
    url: '/user/' + id + '/',
    method: 'get'
  })
}

export function uploadUserAvatar(data) {
  return request({
    url: '/upload/',
    method: 'post',
    data
  })
}

export function resetPassword(id) {
  return request({
    url: '/user/' + id + '/reset_password/',
    method: 'post'
  })
}

export function delUser(id) {
  return request({
    url: '/user/' + id,
    method: 'delete'
  })
}

export function exportUserAll() {
  return request({
    url: '/user/export_all/',
    method: 'post'
  })
}

export function exportUserCurrent(params) {
  return request({
    url: '/user/export_current/',
    method: 'post',
    params
  })
}

export function UserInfoImage(id, data) {
  return request({
    url: '/user/' + id + '/update_image/',
    method: 'post',
    data
  })
}

export function UserInfoPassword(id, data) {
  return request({
    url: '/user/' + id + '/update_password/',
    method: 'post',
    data
  })
}
